//
//  YJconnectionCell.m
//  SnackCourier
//
//  Created by qianfeng01 on 15/7/21.
//  Copyright (c) 2015年 qianfeng01. All rights reserved.
//

#import "YJconnectionCell.h"
#import "YJImmediatelygrabModel.h"
@implementation YJconnectionCell

- (void)awakeFromNib {
    CGFloat w =(self.contentView.frame.size.width-40)/3.0;
    CGFloat h =(self.contentView.frame.size.height)/2.0;
    for (int i=0; i<6; i++) {
        NSArray *nib =[[NSBundle mainBundle] loadNibNamed:@"YJcinnectionCellView" owner:self options:nil];
        _sView =nib.lastObject;
        _sView.frame =CGRectMake(10+(i%3)*(10+w), (i/3)*h, w, h);
        _sView.tag =101+i;
        [self.contentView addSubview:_sView];
        
    }
}
-(void)showDataWithArray:(NSMutableArray *)array myBlock:(YJcinnectionBlock)myBlock{
    self.array =array;
    self.myblock =myBlock;
    for (int i=0; i<array.count; i++) {
        YJcinnectionCellView *view = (YJcinnectionCellView *)[self.contentView viewWithTag:i+101];
        [view showDataWithModel:array[i]];
        [view addtarget:self action:@selector(click:)];
    }
    
}

-(void)click:(YJcinnectionCellView *)view{
    if (self.myblock) {
        YJImmediatelygrabModel *model =self.array[view.tag-101];
        self.myblock(model.id);
    }
    
}


@end
